/*
 * ring_buffer.c
 *
 *  Created on: 20.04.2014
 *      Author: ayoubfalah
 */

#include "io_buffer.h";

#include <stdio.h>
#include  <string.h>

static void init_buffer(io_buffer *buffer, char *char_buffer, int size)
{
	buffer->size = size;
	buffer->read_ptr = 0;

	strcpy(buffer->buffer, char_buffer);

	buffer->write_ptr = strlen(char_buffer);
}

static int get_char(io_buffer *buffer, unsigned short i)
{
    return buffer->buffer[i];
}
static int put_char(io_buffer *buffer, unsigned char c)
{
	short last = buffer->write_ptr;
	strcpy(buffer->buffer[last], c);
	return ++(buffer->write_ptr);
}
static int is_empty(io_buffer *buffer)
{
     return buffer->read_ptr == buffer->write_ptr;
}
static int is_full(io_buffer *buffer)
{
    return strlen(buffer->buffer) == buffer->size;
}
